class MyClass:
    """一个简单的类实例"""
    i = 12345

    def __init__(self):
        self.data = []

    def test(self):
        return 'hello world'


x = MyClass()
print(x.test())


# 无参构造函数
class Test:
    a = 1
    b = 1

    def prt(self):
        print(self)
        print(self.__class__)

    def __init__(self):
        self.a = 10
        self.b = 11


t = Test()
t.prt()
print(t.a)


class Test:
    a = 1

    def __init__(self, a):
        self.a = a

    def prt(self):
        print(self)
        print(self.__class__)


t = Test(a=10)
print(t.a)


class people:
    # 定义基本属性
    name = ''
    age = 0
    # 定义私有属性,私有属性在类外部无法直接进行访问
    __weight = 0

    # 定义构造方法
    def __init__(self, n, a, w):
        self.name = n
        self.age = a
        self.__weight = w

    def speak(self):
        print("%s 说: 我 %d 岁。" % (self.name, self.age))


# 实例化类
p = people('runoob', 10, 30)
p.speak()